<!DOCTYPE HTML>
<html lang="zh_CN">
<head><meta name="generator" content="Hexo 3.8.0">
    <!--Setting-->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <meta http-equiv="Cache-Control" content="no-transform">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta name="apple-mobile-web-app-capable" content="cn華少">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no,email=no,adress=no">
    <meta name="browsermode" content="application">
    <meta name="screen-orientation" content="portrait">
    <link rel="dns-prefetch" href="http://cnhuashao.com">
    <!--SEO-->

    <meta name="keywords" content="tomcat">


    <meta name="description" content="本次安装环境为：系统：Ubuntu16.04.3 server需要的安装包：tomcat9: https://tomcat.apache.org/download-90.cgijdk1.8:  ...">



<meta name="robots" content="all">
<meta name="google" content="all">
<meta name="googlebot" content="all">
<meta name="verify" content="all">

    <!--Title-->


<title>在Ubuntu16.04 Server中安装tomcat9+jdk1.8+apr | cn華少</title>


    <link rel="alternate" href="/atom.xml" title="cn華少" type="application/atom+xml">


    <link rel="icon" href="/favicon/favicon.ico">

    



<link rel="stylesheet" href="/css/bootstrap.min.css?rev=3.3.7">
<link rel="stylesheet" href="/favicons.css">
<link rel="stylesheet" href="/css/style.css?rev=@@hash">




    
	<div class="hide">
		<script type="text/javascript">
			var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan class='cnzz_stat_icon_1263868967 hide' %3E%3Cscript%20src%3D%22https%3A%2F%2Fs95.cnzz.com%2Fz_stat.php%3Fweb_id%3D1272564536%22%3E%3C%2Fscript%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s19.cnzz.com/z_stat.php%3Fid%3D1263868967%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));
		</script>
	</div>






    

</head>

</html>
<!--[if lte IE 8]>
<style>
    html{ font-size: 1em }
</style>
<![endif]-->
<!--[if lte IE 9]>
<div style="ie">你使用的浏览器版本过低，为了你更好的阅读体验，请更新浏览器的版本或者使用其他现代浏览器，比如Chrome、Firefox、Safari等。</div>
<![endif]-->

<body>
    <header class="main-header" style="background-image:url(http://snippet.shenliyang.com/img/banner.jpg)">
    <div class="main-header-box">
        <a class="header-avatar" href="/" title="cn華少">
            <img src="/img/avatar.jpg" alt="logo头像" class="img-responsive center-block">
        </a>
        <div class="branding">
        	<!--<h2 class="text-hide">Snippet主题,从未如此简单有趣</h2>-->
            
                <h2> 追梦，无惧 </h2>
            
    	</div>
    </div>
</header>
    <nav class="main-navigation">
    <div class="container">
        <div class="row">
            <div class="col-sm-12">
                <div class="navbar-header"><span class="nav-toggle-button collapsed pull-right" data-toggle="collapse" data-target="#main-menu" id="mnav">
                    <span class="sr-only"></span>
                        <i class="fa fa-bars"></i>
                    </span>
                    <a class="navbar-brand" href="http://cnhuashao.com">cn華少</a>
                </div>
                <div class="collapse navbar-collapse" id="main-menu">
                    <ul class="menu">
                        
                            <li role="presentation" class="text-center">
                                <a href="/"><i class="fa "></i>首页</a>
                            </li>
                        
                            <li role="presentation" class="text-center">
                                <a href="/categories/java/"><i class="fa "></i>Java</a>
                            </li>
                        
                            <li role="presentation" class="text-center">
                                <a href="/categories/postgresql/"><i class="fa "></i>PostgreSQL</a>
                            </li>
                        
                            <li role="presentation" class="text-center">
                                <a href="/categories/工具/"><i class="fa "></i>工具</a>
                            </li>
                        
                            <li role="presentation" class="text-center">
                                <a href="/archives/"><i class="fa "></i>时间轴</a>
                            </li>
                        
                            <li role="presentation" class="text-center">
                                <a href="/about/"><i class="fa "></i>关于</a>
                            </li>
                        
                    </ul>
                </div>
            </div>
        </div>
    </div>
</nav>
    <section class="content-wrap">
        <div class="container">
            <div class="row">
                <main class="col-md-8 main-content m-post">
                    <p id="process"></p>
<article class="post">
    <div class="post-head">
        <h1 id="在Ubuntu16.04 Server中安装tomcat9+jdk1.8+apr">
            
	            在Ubuntu16.04 Server中安装tomcat9+jdk1.8+apr
            
        </h1>
        <div class="post-meta">
    
        <span class="categories-meta fa-wrap">
            <i class="fa fa-folder-open-o"></i>
            <a class="category-link" href="/categories/tomcat/">tomcat</a>
        </span>
    

    
        <span class="fa-wrap">
            <i class="fa fa-tags"></i>
            <span class="tags-meta">
                
                    <a class="tag-link" href="/tags/tomcat/">tomcat</a>
                
            </span>
        </span>
    

    
        
        <span class="fa-wrap">
            <i class="fa fa-clock-o"></i>
            <span class="date-meta">2019/04/18</span>
        </span>
        
    
</div>
            
            
    </div>
    
    <div class="post-body post-content">
        <h5 id="本次安装环境为："><a href="#本次安装环境为：" class="headerlink" title="本次安装环境为："></a>本次安装环境为：</h5><p>系统：Ubuntu16.04.3 server<br>需要的安装包：<br>tomcat9: <a href="https://tomcat.apache.org/download-90.cgi" target="_blank" rel="noopener">https://tomcat.apache.org/download-90.cgi</a><br>jdk1.8:  <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html" target="_blank" rel="noopener">http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html</a><br>apr1.6.2、apr-iconv1.2.2、apr-util-1.6.0:  <a href="http://apr.apache.org/download.cgi" target="_blank" rel="noopener">http://apr.apache.org/download.cgi</a></p>
<p>也可直接下载我打包好的下载包：<br><a href="https://download.csdn.net/download/csde12/10322753" target="_blank" rel="noopener">https://download.csdn.net/download/csde12/10322753</a></p>
<a id="more"></a>
<h5 id="1、创建jdk与tomcat目录"><a href="#1、创建jdk与tomcat目录" class="headerlink" title="1、创建jdk与tomcat目录"></a>1、创建jdk与tomcat目录</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">sudo mkdir /usr/java</span><br><span class="line">sudo mkdir /usr/tomcat</span><br><span class="line">sudo chown cnHuaShao:cnHuaShao /usr/java</span><br><span class="line">sudo chown cnHuaShao:cnHuaShao /usr/tomcat</span><br></pre></td></tr></table></figure>
<h5 id="2、上传jdk包到-usr-java目录中，上传tomcat与apr包到-usr-tomcat目录中，进入-user-java目录中执行以下命令开始解压jdk"><a href="#2、上传jdk包到-usr-java目录中，上传tomcat与apr包到-usr-tomcat目录中，进入-user-java目录中执行以下命令开始解压jdk" class="headerlink" title="2、上传jdk包到/usr/java目录中，上传tomcat与apr包到/usr/tomcat目录中，进入/user/java目录中执行以下命令开始解压jdk"></a>2、上传jdk包到/usr/java目录中，上传tomcat与apr包到/usr/tomcat目录中，进入/user/java目录中执行以下命令开始解压jdk</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/java</span><br><span class="line">tar -zxf jdk-8u151-linux-x64.tar.gz</span><br></pre></td></tr></table></figure>
<h5 id="3、配置环境变量，这里直接将apr的也配置完成，稍后需要安装时就不需要再配置了。"><a href="#3、配置环境变量，这里直接将apr的也配置完成，稍后需要安装时就不需要再配置了。" class="headerlink" title="3、配置环境变量，这里直接将apr的也配置完成，稍后需要安装时就不需要再配置了。"></a>3、配置环境变量，这里直接将apr的也配置完成，稍后需要安装时就不需要再配置了。</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo vim /etc/profile</span><br></pre></td></tr></table></figure>
<h5 id="4、在该文件的最后增加以下内容"><a href="#4、在该文件的最后增加以下内容" class="headerlink" title="4、在该文件的最后增加以下内容"></a>4、在该文件的最后增加以下内容</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">JAVA_HOME=/usr/java/jdk1.8.0_151</span><br><span class="line">JRE_HOME=$JAVA_HOME/jre</span><br><span class="line">PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin</span><br><span class="line">CLASSPATH=:$JRE_HOME/lib/rt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib/dt.jar</span><br><span class="line">export JAVA_HOME JRE_HOME PATH CLASSPATH</span><br><span class="line">export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib</span><br><span class="line">export LD_RUN_PATH=$LD_RUN_PATH:/usr/local/apr/lib</span><br></pre></td></tr></table></figure>
<h6 id="立即生效，可以通过java-version-、java、javac命令进行测试是否成功"><a href="#立即生效，可以通过java-version-、java、javac命令进行测试是否成功" class="headerlink" title="立即生效，可以通过java -version 、java、javac命令进行测试是否成功"></a>立即生效，可以通过java -version 、java、javac命令进行测试是否成功</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">source /etc/profile</span><br></pre></td></tr></table></figure>
<h5 id="5、进入-usr-tomcat目录中进行解压tomcat包和apr包"><a href="#5、进入-usr-tomcat目录中进行解压tomcat包和apr包" class="headerlink" title="5、进入/usr/tomcat目录中进行解压tomcat包和apr包"></a>5、进入/usr/tomcat目录中进行解压tomcat包和apr包</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">tar -zxf apache-tomcat-9.0.2.tar.gz</span><br><span class="line">tar -zxf apr-1.6.2.tar.gz</span><br><span class="line">tar -zxf apr-iconv-1.2.2.tar.gz</span><br><span class="line">tar -zxf apr-util-1.6.0.tar.gz</span><br></pre></td></tr></table></figure>
<h5 id="6、安装apr需要的所有基础包"><a href="#6、安装apr需要的所有基础包" class="headerlink" title="6、安装apr需要的所有基础包"></a>6、安装apr需要的所有基础包</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install -y libtool libapr1 make gcc libexpat1-dev expat-devel</span><br></pre></td></tr></table></figure>
<h5 id="7、安装apr基础包"><a href="#7、安装apr基础包" class="headerlink" title="7、安装apr基础包"></a>7、安装apr基础包</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/tomcat/apr-1.6.2</span><br><span class="line">sudo ./configure &amp;&amp; sudo make &amp;&amp; sudo make install</span><br></pre></td></tr></table></figure>
<h5 id="8、安装apr-iconv包"><a href="#8、安装apr-iconv包" class="headerlink" title="8、安装apr-iconv包"></a>8、安装apr-iconv包</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/tomcat/apr-iconv-1.2.2</span><br><span class="line">sudo ./configure --with-apr=/usr/local/apr &amp;&amp; sudo make &amp;&amp; sudo make install</span><br></pre></td></tr></table></figure>
<h5 id="9、安装apr-util包"><a href="#9、安装apr-util包" class="headerlink" title="9、安装apr-util包"></a>9、安装apr-util包</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/tomcat/apr-util-1.6.0</span><br><span class="line">sudo ./configure --with-apr=/usr/local/apr --with-iconv=/usr/local/apache2 &amp;&amp; sudo make &amp;&amp; sudo make install</span><br></pre></td></tr></table></figure>
<h5 id="10、安装tomcat集成apr插件包"><a href="#10、安装tomcat集成apr插件包" class="headerlink" title="10、安装tomcat集成apr插件包"></a>10、安装tomcat集成apr插件包</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/tomcat/apache-tomcat-9.0.2/bin/</span><br><span class="line">tar -zxf tomcat-native.tar.gz</span><br><span class="line">cd tomcat-native-1.2.16-src/native/</span><br><span class="line">sudo ./configure --with-apr=/usr/local/apr --with-java-home=$JAVA_HOME &amp;&amp; sudo make &amp;&amp; sudo make install</span><br><span class="line">sudo ln -s /usr/local/apr/lib/libtcnative-1.so /usr/lib/libcnative-1.so</span><br></pre></td></tr></table></figure>
<h5 id="11、进行调整tomcat参数"><a href="#11、进行调整tomcat参数" class="headerlink" title="11、进行调整tomcat参数"></a>11、进行调整tomcat参数</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/tomcat/apache-tomcat-9.0.2/</span><br><span class="line">vim  conf/server.xml</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;Listener className=&quot;org.apache.catalina.core.AprLifecycleListener&quot; SSLEngine=&quot;off&quot; /&gt;</span><br><span class="line">&lt;Connector executor=&quot;tomcatThreadPool&quot;</span><br><span class="line">               port=&quot;8080&quot; protocol=&quot;org.apache.coyote.http11.Http11AprProtocol&quot;</span><br><span class="line">               URIEncoding=&quot;UTF-8&quot; enableLookups=&quot;false&quot; acceptCount=&quot;50&quot;</span><br><span class="line">               connectionTimeout=&quot;1000&quot; maxKeepAliveRequests=&quot;250&quot;</span><br><span class="line">               redirectPort=&quot;8443&quot; /&gt;</span><br></pre></td></tr></table></figure>
<p>删除配置文件中的user相关配置，解决漏洞问题。</p>
<p>启动时可能会变慢，修改启动项，这里参考文章<a href="https://www.cnblogs.com/devilwind/p/6902037.html" target="_blank" rel="noopener">https://www.cnblogs.com/devilwind/p/6902037.html</a><br>vim bin/catalina.sh<br>加入JAVA_OPTS=”-Djava.security.egd=file:/dev/./urandom”这个配置</p>
<h5 id="12、进行启动测试"><a href="#12、进行启动测试" class="headerlink" title="12、进行启动测试"></a>12、进行启动测试</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">bin/startup.sh </span><br><span class="line">tail -1000f logs/catalina.out</span><br></pre></td></tr></table></figure>
<p>至此本次的环境安装完成。</p>

    </div>
    
        <div class="reward" ontouchstart>
    <div class="reward-wrap">赏
        <div class="reward-box">
            
                <span class="reward-type">
                    <img class="alipay" src="/img/alipay.jpg"><b>支付宝打赏</b>
                </span>
            
            
                <span class="reward-type">
                    <img class="wechat" src="/img/wepay.jpg"><b>微信打赏</b>
                </span>
            
        </div>
    </div>
    <p class="reward-tip">赞赏是不耍流氓的鼓励</p>
</div>


    
    <div class="post-footer">
        <div>
            
                转载声明：商业转载请联系作者获得授权,非商业转载请注明出处 © <a href target="_blank">Snippet</a>
            
        </div>
        <div>
            
        </div>
    </div>
</article>

<div class="article-nav prev-next-wrap clearfix">
    
        <a href="/2019/04/18/IDEA-IntelliJ-SVN/" class="pre-post btn btn-default" title="在IntelliJ IDEA上面进行使用svn进行版本管理">
            <i class="fa fa-angle-left fa-fw"></i><span class="hidden-lg">上一篇</span>
            <span class="hidden-xs">在IntelliJ IDEA上面进行使用svn进行版本管理</span>
        </a>
    
    
        <a href="/2019/04/18/owncloud-init/" class="next-post btn btn-default" title="在ubuntu16.04上安装owncloud">
            <span class="hidden-lg">下一篇</span>
            <span class="hidden-xs">在ubuntu16.04上安装owncloud</span><i class="fa fa-angle-right fa-fw"></i>
        </a>
    
</div>


    <div id="comments">
        
	
    <div id="vcomments" class="valine"></div>
    <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="/assets/valine.min.js"></script>

    <script>
        new Valine({
            av: AV,
            el: '#vcomments',
            appId: 'xOKV9J4UeQAtVkvnJC7Kq2Jn-gzGzoHsz',
            appKey: 'erIpQac4azoCmgfBB7Dl9maa',
            placeholder: '说点什么吧',
            notify: false,
            verify: false,
            avatar: 'mm',
            meta: 'nick,mail'.split(','),
            pageSize: '10',
            path: window.location.pathname,
            lang: 'zh_CN'.toLowerCase()
        })
    </script>


    </div>





                </main>
                
                    <aside id="article-toc" role="navigation" class="col-md-4">
    <div class="widget">
        <h3 class="title">Table of Contents</h3>
        
            <ol class="toc"><li class="toc-item toc-level-5"><a class="toc-link" href="#本次安装环境为："><span class="toc-text">本次安装环境为：</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#1、创建jdk与tomcat目录"><span class="toc-text">1、创建jdk与tomcat目录</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#2、上传jdk包到-usr-java目录中，上传tomcat与apr包到-usr-tomcat目录中，进入-user-java目录中执行以下命令开始解压jdk"><span class="toc-text">2、上传jdk包到/usr/java目录中，上传tomcat与apr包到/usr/tomcat目录中，进入/user/java目录中执行以下命令开始解压jdk</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#3、配置环境变量，这里直接将apr的也配置完成，稍后需要安装时就不需要再配置了。"><span class="toc-text">3、配置环境变量，这里直接将apr的也配置完成，稍后需要安装时就不需要再配置了。</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#4、在该文件的最后增加以下内容"><span class="toc-text">4、在该文件的最后增加以下内容</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#立即生效，可以通过java-version-、java、javac命令进行测试是否成功"><span class="toc-text">立即生效，可以通过java -version 、java、javac命令进行测试是否成功</span></a></li></ol></li><li class="toc-item toc-level-5"><a class="toc-link" href="#5、进入-usr-tomcat目录中进行解压tomcat包和apr包"><span class="toc-text">5、进入/usr/tomcat目录中进行解压tomcat包和apr包</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#6、安装apr需要的所有基础包"><span class="toc-text">6、安装apr需要的所有基础包</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#7、安装apr基础包"><span class="toc-text">7、安装apr基础包</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#8、安装apr-iconv包"><span class="toc-text">8、安装apr-iconv包</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#9、安装apr-util包"><span class="toc-text">9、安装apr-util包</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#10、安装tomcat集成apr插件包"><span class="toc-text">10、安装tomcat集成apr插件包</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#11、进行调整tomcat参数"><span class="toc-text">11、进行调整tomcat参数</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#12、进行启动测试"><span class="toc-text">12、进行启动测试</span></a></li></ol>
        
    </div>
</aside>

                
            </div>
        </div>
    </section>
    <footer class="main-footer">
    <div class="container">
        <div class="row">
        </div>
    </div>
</footer>

<a id="back-to-top" class="icon-btn hide">
	<i class="fa fa-chevron-up"></i>
</a>




    <div class="copyright">
    <div class="container">
        <div class="row">
            <div class="col-sm-12">
                <div class="busuanzi">
    
</div>

            </div>
            <div class="col-sm-12">
                <span>Copyright &copy; 2017
                </span> |
                <span>
                    Powered by <a href="//hexo.io" class="copyright-links" target="_blank" rel="nofollow">Hexo</a>
                </span> |
                <span>
                    Theme by <a href="//github.com/shenliyang/hexo-theme-snippet.git" class="copyright-links" target="_blank" rel="nofollow">Snippet</a>
                </span>
            </div>
        </div>
    </div>
</div>







<script src="/js/app.js?rev=@@hash"></script>

</body>
</html>